#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

const int N = 1e6 + 10, INF = 0x3f3f3f3f;

int n, m;
int a[N];
ll pre[N];

void solve()
{
    cin >> n >> m;
    for (int i = 0;i < n;i++) {
        cin >> a[i];
        a[i + n] = a[i];
    }
    int n2 = n * 2;
    pre[0] = a[0];
    for (int i = 1;i < n2;i++) pre[i] += pre[i - 1] + a[i];

    int p = 0;
    while (m--) {
        int op;cin >> op;
        if (op == 1) {
            int x;cin >> x;
            p = (p + x) % n;
        } else {
            int l, r;cin >> l >> r;
            l--, r--;
            cout << pre[p + r] - (p + l - 1 < 0 ? 0 : pre[p + l - 1]) << '\n';
        }
    }
}

signed main()
{
    //ios::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
    std::istringstream in(R"(4 3
3 1 4 5
2 1 3
1 1
2 2 3
)");
    std::cin.rdbuf(in.rdbuf());
#endif
    int T = 1;
    //cin>>T;
    for (int i = 1;i <= T;i++) {
        solve();
    }
}